package com.biz.primus.ms.thirdlogin.oauth.service;

import com.biz.primus.model.thirdlogin.enums.OAuthTypes;
import org.scribe.model.OAuthRequest;
import org.scribe.model.Token;
import org.scribe.model.Verifier;
import org.scribe.oauth.OAuthService;

/**
 * @author jun.liu
 * @date 2017/9/29
 */
public abstract class OAuthServiceDeractor implements CustomOAuthService
{

    private final OAuthService oAuthService;
    private final OAuthTypes oAuthType;
    private final String authorizationUrl;

    public OAuthServiceDeractor(OAuthService oAuthService, OAuthTypes type)
    {
        super();
        this.oAuthService = oAuthService;
        this.oAuthType = type;
        this.authorizationUrl = oAuthService.getAuthorizationUrl(null);
    }

    @Override
    public Token getRequestToken() {
        return oAuthService.getRequestToken();
    }

    @Override
    public Token getAccessToken(Token requestToken, Verifier verifier)
    {
        return oAuthService.getAccessToken(requestToken, verifier);
    }

    @Override
    public void signRequest(Token accessToken, OAuthRequest request) {
        oAuthService.signRequest(accessToken, request);
    }

    @Override
    public String getVersion() {
        return oAuthService.getVersion();
    }

    @Override
    public String getAuthorizationUrl(Token requestToken) {
        return oAuthService.getAuthorizationUrl(requestToken);
    }

    @Override
    public OAuthTypes getOAuthType() {
        return oAuthType;
    }

    @Override
    public String getAuthorizationUrl() {
        return authorizationUrl;
    }

}
